{% set pypi_name = 'metalsmith' %}
{% set upstream_version = upstream_version('1.3.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Bare metal provisioner using Ironic
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  {{ py3('ansible') }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PrettyTable') }}
BuildRequires:  {{ py3('openstacksdk') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Simple Python library and CLI tool to provision bare metal machines using
OpenStack Ironic.

%package -n python3-metalsmith
Summary:        Bare metal provisioner using Ironic
Requires:       {{ py3('ansible') }}
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('openstacksdk') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('requests') }}

%description -n python3-metalsmith
Simple Python library and CLI tool to provision bare metal machines using
OpenStack Ironic.

%package -n {{ py2name() }}-doc
Summary:        Documentation for Metalsmith
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}
BuildRequires:  {{ py3('sphinxcontrib-svg2pdfconverter') }}

%description -n {{ py2name() }}-doc
Documentation for Metalsmith

%package -n ansible-role-{{ py2name() }}-deployment
Summary:        Ansible role for Metalsmith deployment
Requires:       {{ py3('metalsmith') }}

%description -n ansible-role-{{ py2name() }}-deployment
Ansible role for Metalsmith deployment

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n python3-metalsmith
%license LICENSE
%{_bindir}/metalsmith
%{python3_sitelib}/metalsmith
%{python3_sitelib}/*.egg-info

%files -n {{ py2name() }}-doc
%license LICENSE
%doc doc/build/html README.rst

%files -n ansible-role-{{ py2name() }}-deployment
%license LICENSE
%doc metalsmith_ansible/roles/metalsmith_deployment/README.rst
%{_datadir}/ansible
%{_datadir}/ansible/roles
%{_datadir}/ansible/roles/metalsmith_deployment
%exclude %{_datadir}/ansible/roles/metalsmith_deployment/README.rst

%changelog
